package com.bw.mvvm_common.bind;

import androidx.databinding.BindingAdapter;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;

public
/**
 * @author Lishaohe
 * @description:
 * @date :2021/10/14 0014 下午 6:47
 *
 */
class BasicRvBind {
    @BindingAdapter(value = "adapter")
    public static void bindAdapter(RecyclerView recyclerView, BaseQuickAdapter adapter){
        if (adapter==null){
            return;
        }
        recyclerView.setAdapter(adapter);
    }
    @BindingAdapter(value = "orientation")
    public static void bindLinearManager(RecyclerView recyclerView,int orientation){
        LinearLayoutManager manager = new LinearLayoutManager(recyclerView.getContext());
        manager.setOrientation(orientation);
        recyclerView.setLayoutManager(manager);
    }
    @BindingAdapter(value = {"gridorientation","rvnum"})
    public static void bindGridManager(RecyclerView recyclerView,int gridorientation,int rvnum){
        GridLayoutManager manager = new GridLayoutManager(recyclerView.getContext(), rvnum);
        manager.setOrientation(gridorientation);
        recyclerView.setLayoutManager(manager);
    }
}
